/*
 * @Descripttion: 
 * @version: 
 * @Author: 高月飞
 * @Date: 2023-11-17 20:07:16
 * @LastEditors: 高月飞
 * @LastEditTime: 2023-11-18 14:18:50
 */

import type { RouteRecordRaw } from "vue-router";
/**
 * 自动引入routes 的路由
 * 定义子路由数组
 * 遍历放入
 */
const files = import.meta.glob('./routes/*.ts', { eager: true })

export const children = [] as RouteRecordRaw[]

for (let key in files) {
    let route = (files[key as keyof typeof files] as any).default
    if (Array.isArray(route)) {
        children.push(...route)
    } else {
        children.push(route)
    }
}

const routes: RouteRecordRaw[] = [
    {
        path: "/",
        redirect: "/dashoard/newData",
        component: () => import('@/views/Admin/index.vue'),
        meta: {
            menu: "",
            icon: ""
        },
        children
    },
    {
        path: "/login",
        name: "login",
        component: () => import('@/views/Login/index.vue'),
        meta: {
            nologin: true,
            menu: "",
            icon: ""
        }
    },
    {
        path: '/:pathMatch(.*)*',
        name: '404',
        component: () => import('@/views/404/index.vue'),
        meta: {
            menu: "",
            icon: ""
        }
    },
]
export default routes